import Vue from 'vue'
import Router from 'vue-router'
import Index from '@/views/Index'
import Mine from '@/views/index/Mine'
import DocManage from '@/views/index/DocManage'
import Important from '@/views/index/Important'
import ProManage from '@/views/index/ProManage'
import Petition from '@/views/index/Petition'
import HouApproval from '@/views/index/HouApproval'
import PeoManage from '@/views/index/PeoManage'
import AddressBook from '@/views/index/AddressBook'
import NewMeet from '@/views/second/NewMeet'
import Leave from '@/views/second/Leave'
import Decision from '@/views/second/Decision'
import Creation from '@/views/second/Creation'
import Project from '@/views/second/Project'
import Draft from '@/views/second/Draft'
import chart from '@/views/second/chart'
import PostDraft from '@/views/second/PostDraft'
import NewDraft from '@/views/second/NewDraft'
import PostSelect from '@/views/second/PostSelect'
import PullSelect from '@/views/second/PullSelect'
import Apply from '@/views/second/Apply'
// import decision from '@/views/second/decision'


Vue.use(Router)

const router = new Router({
  routes: [
    {
      path: '/',
      name: 'Index',
      component: Index,
      meta: {
        title: '首页'
      },
      redirect: '/index/mine',
      children: [
        {
          path: '/index/mine',
          name: 'Mine',
          component: Mine
        },
        {
          path: '/index/docmanage',
          name: 'DocManage',
          component: DocManage
        },
        {
          path: '/index/important',
          name: 'Important',
          component: Important
        },
        {
          path: '/index/promanage',
          name: 'ProManage',
          component: ProManage
        },
        {
          path: '/index/petition',
          name: 'Petition',
          component: Petition
        },
        {
          path: '/index/houapproval',
          name: 'HouApproval',
          component: HouApproval
        },
        {
          path: '/index/peomanage',
          name: 'PeoManage',
          component: PeoManage
        },
        {
          path: '/index/addressbook',
          name: 'AddressBook',
          component: AddressBook
        }
      ]
    },
    {
      path: '/newmeet',
      name: 'NewMeet',
      component: NewMeet,
      meta: {
        title: '新建'
      },
    },
    {
      path: '/leave',
      name: 'Leave',
      component: Leave,
      meta: {
        title: '请假'
      }
    },
    {
      path: '/echart1',
      name: 'chart',
      component: chart,
      meta: {
        title: '图表'
      },
    },
    {
      path: '/decision ',
      name: 'Decision ',
      component: Decision,
      meta: {
        title: '新增决策事项'
      }
    },
    {
      path: '/creation ',
      name: 'Creation ',
      component: Creation,
      meta: {
        title: '信访流程创建'
      }
    },
      
    {
      path: '/project',
      name: 'Project',
      component: Project,
      meta: {
        title: '新增项目'
      },
    },
    {
      path: '/draft',
      name: 'Draft',
      component: Draft,
      meta: {
        title: '管理'
      },
      redirect: '/postDraft',
      children: [
        {
          path: '/postDraft',
          name: 'PostDraft',
          component: PostDraft
        },
        {
          path: '/newDraft',
          name: 'NewDraft',
          component: NewDraft
        },
        {
          path: '/postSelect',
          name: 'PostSelect',
          component: PostSelect
        },
        {
          path: '/pullSelect',
          name: 'PullSelect',
          component: PullSelect
        }
      ]
    },
    {
      path:'/apply',
      name:'Apply',
      component: Apply ,
      meta: {
        title: '决策会议申请'
      },
    },
    
    // {
    //   path: '/decision ',
    //   name: 'decision ',
    //   component: decision ,
    //   meta: {
    //     title: '新建'
    //   },
    // },
  ],
  mode: 'history'
})

//前置钩子，显示标题
router.beforeEach((to, from, next) => {
  if (to.meta.title) {
    document.title = to.meta.title;
  }
  next();
})

export default router;
